<ui:composition template="/template.xhtml"
				xmlns="http://www.w3.org/1999/xhtml"
				xmlns:ui="http://java.sun.com/jsf/facelets"
				xmlns:h="http://java.sun.com/jsf/html"
				xmlns:f="http://java.sun.com/jsf/core">
	
	<ui:define name="conteudo">
		
		<h1>Cadastro de Usuário</h1>
		<h:form>
			<h:messages />
			<h:inputHidden value="#{usuarioBean.usuario.id}" />
			<h:inputHidden value="#{usuarioBean.usuario.ativo}" />
			
			<h:panelGrid columns="2">
			
				<h:outputLabel value="Nome: " for="nome"/>
				<h:inputText id="nome" label="Nome" value="#{usuarioBean.usuario.nome}" size="50" maxlength="50" required="true" requiredMessage="Qual o seu nome?">
					<f:validateLength minimum="10" maximum="50"/>
				</h:inputText>
				
				<h:outputLabel value="Data Nascimento: " for="data"/>
				<h:inputText id="data" label="Data" value="#{usuarioBean.usuario.nascimento}" size="10" maxlength="10" required="true" requiredMessage="Qual a sua data de nascimento?">
					<f:convertDateTime dateStyle="medium" />
				</h:inputText>
				
				<h:outputLabel value="e-Mail: " for="email"/>
				<h:panelGroup>
					<h:inputText id="email" label="e-Mail" value="#{usuarioBean.usuario.email}" size="50" maxlength="50" required="true" validatorMessage="e-Mail Inválido." />
					<h:message for="email" />
				</h:panelGroup>
				
				<h:outputLabel value="Login: " for="login" />
				<h:inputText id="login" label="login" value="#{usuarioBean.usuario.login}" size="15" maxlength="15" required="true" 
					validatorMessage="Login deve ter no mínimo 5 e no máximo 15 caracteres e só pode ter os símbolos '.' e '_'." >
					<f:validateRegex pattern="([a-z]|[0-9]|[.]|[_]){5,15}" />
				</h:inputText>
				
				<h:outputLabel value="Senha: " for="senha"/>
				<h:inputSecret id="senha" label="Senha" value="#{usuarioBean.usuario.senha}" size="10" maxlength="10" required="true" redisplay="true" />
				
			</h:panelGrid>
			
			<h:commandButton action="#{usuarioBean.cadastrarUsuario}" value="Salvar"/>
					
		</h:form>
				
		
	</ui:define>
	
</ui:composition>